#! /usr/bin/env python:
# -*- coding: utf-8 -*-

# *************************************************************
#     Filename @  deco.py
#       Author @  Huoty
#  Create date @  2014-10-24 10:09:52
#  Description @  
# *************************************************************


from time import ctime, sleep

def tsfunc(func):
    def wrapperFunc():
        print "[%s] %s() called" % (ctime(), func.__name__)
        return func()
    return wrapperFunc  # 相当于返回一个函数指针

@tsfunc        
def foo():
    def foo():
        pass
# foo = tsfunc(foo)，tsfunc返回wrapperFunc，即foo 变成了 wrapperFunc
# 所以调用foo, 就等于是调用了wrapperFunc    ********
# 也可以说wrapperFunc是装饰过的func

# Script starts from here
foo()
sleep(4)

for i in range(2):
    sleep(1)
    foo()
